package com.chartboost.sdk;

import android.app.Activity;
import android.os.Handler;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout.LayoutParams;
import com.chartboost.sdk.impl.a.c;
import com.chartboost.sdk.impl.n;
import com.chartboost.sdk.impl.n.a;
import com.chartboost.sdk.impl.n.b;
import com.chartboost.sdk.impl.o;
import com.chartboost.sdk.impl.r;
import com.chartboost.sdk.impl.s;
import org.json.JSONObject;

public final class a
{
  private Chartboost a;
  private Activity b;
  private r c;
  private boolean d = false;
  private boolean e = false;
  private boolean f = false;
  private s g;
  private s h;

  protected a(Chartboost paramChartboost, Activity paramActivity)
  {
    this.a = paramChartboost;
    this.b = paramActivity;
  }

  private void b()
  {
    this.c = new r(this.b);
    this.h = new s(this.b, this.c);
    this.h.b().a(true);
    this.b.addContentView(this.h, new FrameLayout.LayoutParams(-1, -1));
    this.h.b().a();
    this.h.b().a((View)this.c.getParent());
    this.d = true;
  }

  private void b(com.chartboost.sdk.impl.a parama)
  {
    if (this.e);
    ChartboostDelegate localChartboostDelegate;
    do
    {
      do
      {
        do
        {
          return;
          parama.c = com.chartboost.sdk.impl.a.b.b;
          if (parama.f.b())
            break;
        }
        while (parama.f.d == null);
        parama.f.d.a();
        return;
        if (parama.i)
        {
          parama.i = false;
          this.g = new s(this.b, parama.f.d());
          this.b.addContentView(this.g, new FrameLayout.LayoutParams(-1, -1));
          parama.c = com.chartboost.sdk.impl.a.b.c;
          parama.h = this.g;
          this.e = true;
          return;
        }
        this.g = new s(this.b, parama.f.d());
        this.b.addContentView(this.g, new FrameLayout.LayoutParams(-1, -1));
        this.g.b().a();
        n.b localb = n.b.b;
        if (parama.d == a.c.c)
          localb = n.b.d;
        if (parama.a.optInt("animation") != 0)
          localb = n.b.values()[parama.a.optInt("animation")];
        parama.c = com.chartboost.sdk.impl.a.b.c;
        parama.h = this.g;
        n.a(localb, parama);
        this.e = true;
        localChartboostDelegate = this.a.getDelegate();
      }
      while (localChartboostDelegate == null);
      if (parama.d == a.c.b)
      {
        localChartboostDelegate.didShowInterstitial(parama.e);
        return;
      }
    }
    while (parama.d != a.c.c);
    localChartboostDelegate.didShowMoreApps();
  }

  private n.a c(com.chartboost.sdk.impl.a parama)
  {
    return new n.a()
    {
      public void a(com.chartboost.sdk.impl.a paramAnonymousa)
      {
        a.a(a.this).a.post(new a.b(a.this, paramAnonymousa, false));
      }
    };
  }

  protected void a(Activity paramActivity)
  {
    this.b = paramActivity;
  }

  protected void a(a parama)
  {
    if (parama.a)
      b();
    while (parama.b == null)
      return;
    b(parama.b);
  }

  public void a(com.chartboost.sdk.impl.a parama)
  {
    this.e = false;
    new b(parama, true).run();
    if (parama.c == com.chartboost.sdk.impl.a.b.c)
      parama.c = com.chartboost.sdk.impl.a.b.b;
    while (true)
    {
      parama.c();
      try
      {
        ((ViewGroup)this.g.getParent()).removeView(this.g);
        return;
        parama.c = com.chartboost.sdk.impl.a.b.a;
      }
      catch (Exception localException)
      {
      }
    }
  }

  public void a(com.chartboost.sdk.impl.a parama, boolean paramBoolean)
  {
    this.e = false;
    if (!paramBoolean)
      this.f = true;
    parama.c = com.chartboost.sdk.impl.a.b.d;
    n.b localb = n.b.b;
    if (parama.d == a.c.c)
      localb = n.b.d;
    if (parama.a.optInt("animation") != 0)
      localb = n.b.values()[parama.a.optInt("animation")];
    n.b(localb, parama, c(parama));
  }

  public void a(boolean paramBoolean)
  {
    if (a());
    try
    {
      ((ViewGroup)this.h.getParent()).removeView(this.h);
      this.c = null;
      this.h = null;
      this.d = false;
      if ((!this.f) && (paramBoolean) && (this.a.getImpressionsUseActivities()) && (!this.e) && ((this.b instanceof CBImpressionActivity)))
      {
        this.a.c();
        this.b.finish();
      }
      return;
    }
    catch (Exception localException)
    {
      while (true)
        localException.printStackTrace();
    }
  }

  protected boolean a()
  {
    return this.d;
  }

  public void b(com.chartboost.sdk.impl.a parama, boolean paramBoolean)
  {
    if (this.g == null);
    while (true)
    {
      return;
      try
      {
        ((ViewGroup)this.g.getParent()).removeView(this.g);
        parama.b();
        this.g = null;
        this.f = false;
        if ((!this.a.getImpressionsUseActivities()) || (paramBoolean) || (this.d) || (!(this.b instanceof CBImpressionActivity)))
          continue;
        this.a.c();
        this.b.finish();
        return;
      }
      catch (Exception localException)
      {
        while (true)
          localException.printStackTrace();
      }
    }
  }

  protected static final class a
  {
    protected boolean a;
    protected com.chartboost.sdk.impl.a b;

    public a(com.chartboost.sdk.impl.a parama)
    {
      this.a = false;
      this.b = parama;
    }

    protected a(boolean paramBoolean, com.chartboost.sdk.impl.a parama)
    {
      this.a = paramBoolean;
      this.b = parama;
    }
  }

  private class b
    implements Runnable
  {
    private com.chartboost.sdk.impl.a b;
    private boolean c;

    public b(com.chartboost.sdk.impl.a paramBoolean, boolean arg3)
    {
      this.b = paramBoolean;
      boolean bool;
      this.c = bool;
    }

    public void run()
    {
      if (this.b.c == com.chartboost.sdk.impl.a.b.d)
      {
        this.b.c = com.chartboost.sdk.impl.a.b.a;
        a.this.b(this.b, this.c);
      }
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.chartboost.sdk.a
 * JD-Core Version:    0.6.2
 */